{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style type="text/css">
  #des, #des input {
    width: 40px;
    text-align: center;
  }
  #id {
    width: 78px;
  }
  .bs-checkbox {
    width: 36px;
    height: 40px
  }
  .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
    margin-left: 0px;
    margin-top: 0px
  }
  #title span {
    float: right;
    margin-left: 3.333px;
  }
  .search {
    margin-bottom: 0px !important;
  }
  .asdlkjasd {
    background: #1ab394;
    color: #fff
  }
  #title {
    position: relative;
    padding-right: 50px;
  }
  #title span {
    position: absolute;
    top: 12px;
    right: 10px;
  }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content {:config('adminClass.main')}">
  <div class="ibox float-e-margins">
    {include file="public/tophead"}
    {include file="public/top" /}
    <div class="ibox-content">
      {include file="public/topsection"}
      <div class="row row-lg">
        <div class="col-sm-12">
          <div class="fixed-table-toolbar">
              <a class="btn btn-default btn-outline {notpresent name='is_hidden'}asdlkjasd{/notpresent}" href="{:url('list')}{present name='state'}/state/{$state}{/present}">全部</a>
              <a class="btn btn-default btn-outline {present name='is_hidden'}{eq name='is_hidden' value='0'}asdlkjasd{/eq}{/present}" href="{:url('list',['is_hidden' => 0])}{present name='state'}/state/{$state}{/present}">显示</a>
              <a class="btn btn-default btn-outline {present name='is_hidden'}{eq name='is_hidden' value='1'}asdlkjasd{/eq}{/present}" href="{:url('list',['is_hidden' => 1])}{present name='state'}/state/{$state}{/present}">隐藏</a>
          </div>
          <div class="fixed-table-toolbar">
              <a class="btn btn-default btn-outline {notpresent name='state'}asdlkjasd{/notpresent}" href="{:url('list')}{present name='is_hidden'}/is_hidden/{$is_hidden}{/present}">全 部</a>
              <a class="btn btn-default btn-outline {present name='state'}{eq name='state' value='0'}asdlkjasd{/eq}{/present}" href="{:url('list',['state' => 0])}{present name='is_hidden'}/is_hidden/{$is_hidden}{/present}">未开始</a>
              <a class="btn btn-default btn-outline {present name='state'}{eq name='state' value='1'}asdlkjasd{/eq}{/present}" href="{:url('list',['state' => 1])}{present name='is_hidden'}/is_hidden/{$is_hidden}{/present}">进行中</a>
              <a class="btn btn-default btn-outline {present name='state'}{eq name='state' value='2'}asdlkjasd{/eq}{/present}" href="{:url('list',['state' => 2])}{present name='is_hidden'}/is_hidden/{$is_hidden}{/present}">已结束</a>
          </div>
          <div class="fixed-table-toolbar">
            <form  method="get" action="">
              <div class="pull-left search">
                {php}
                if(input('?param.name')){
                {/php}
                <div class="pull-right search">
                  <a class="btn btn-w-m btn-link" href="{:url('list')}">返回管理</a>
                </div>{php}
                }
                {/php}
                <div class="columns columns-right btn-group pull-left" >
                  <select class="form-control" name="search">
                    <option value="title">标题</option>
                    <option value="content" {present name='search'}{eq name='search' value='content'}selected{/eq}{/present}>内容</option>
                  </select>
                </div>


                <div class="pull-right search" style="display: flex;">
                  <input name="start" type="text" id="start" class="form-control layui-input" value="{present name='start'}{$start}{/present}" placeholder=" # 起始时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">
                  <input name="end" type="text" id="end" class="form-control layui-input" value="{present name='end'}{$end}{/present}" placeholder=" # 结束时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">
                </div>


                <div class="pull-right search">
                  <button style="border-radius:0px; border:1px solid #e5e6e7; border-left:0px" class="btn btn-default btn-outline" type="submit">搜索</button>
                </div>
                <div class="pull-right search">
                  <input class="form-control input-outline" id="filter" type="text"
                         {php}
                         if(input('?param.name')){
                  if(input('param.name')){
                  echo "value='".input('name')."'";
                  }

                  }
                  {/php}
                  name="name" placeholder="">
                </div>
              </div>
            </form>
          </div>

          <div style="display:block;clear: both;"></div>

          <div class="example">
            <form class="form-horizontal" method="post">
              <table data-toggle="table">
                <thead>
                <tr>
                  <th class="bs-checkbox"><input type="checkbox" id="delidAll"></th>
                  <th>id</th>
                  <th>标题</th>
                  <th>封面</th>
                  <th>排序</th>
                  <th>状态</th>
                  <th>活动时间</th>
                  <th>创建时间</th>
                  <th>修改时间</th>
                  <th>管理</th>
                </tr>
                </thead>
                <tbody id="form">
                {volist name="data" id="v"}
                <tr id="id{$v.id}" class="class">
                  <td id="delid" ><input name="delAll[]" type="checkbox" value="{$v.id}"></td>
                  <td>{$v.id}</td>
                  <td id="name">{$v.title}</td>
                  <td>
                    {if condition="$v.image"}
                      <a href="__ROOT__{$v.image}" target="_blank">
                          <img style="max-height:50px;" src="__ROOT__{$v.image}"/>
                      </a>
                    {/if}
                  </td>
                  <td>{$v.sort}</td>
                  <td>{$v.is_hidden?'隐藏':'显示'}</td>
                  <td>{$v.start_time|date='Y-m-d H:i:s',###} - {$v.end_time|date='Y-m-d H:i:s',###}</td>
                  <td><span {php}if(date('Ymd')==date('Ymd',$v['create_time']))echo 'style="color: #ed5565"';{/php}>{$v.create_time|date='Y-m-d H:i:s',###}</span></td>
                  <td><span {php}if(date('Ymd')==date('Ymd',$v['update_time']))echo 'style="color: #ed5565"';{/php}>{$v.update_time|date='Y-m-d H:i:s',###}</span></td>
                  <td>
                    <div class="btn-group">
                      <div data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span>
                      </div>
                      <ul class="dropdown-menu">
                        <li><a onClick="add('{:url('addList',['id'=>$v['id'],'url'=>-1])}')">修改</a></li>
                        <li class="divider"></li>
                        
                        <li class="divider"></li>
                        <li><a onclick="del({$v.id})">删除</a>
                        </li>
                      </ul>
                    </div>
                  </td>
                </tr>
                {/volist}
                </tbody>
              </table>
            </form>
          </div>
        </div>
      </div>
      <hr>
      <div class="row row-lg">
        <div class="col-sm-12 pages">{$page}</div>
      </div>
    </div>
  </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
  $(document).ready(function(){
    $('#delidAll').click(function(){
        $('input[type=checkbox]').each(function(){
            var self=$(this);
            if(!self.prop('checked')){
                self.prop('checked',true);
            }else{
                self.prop('checked',false);
            }
        });
    })
    layui.use(['laydate'], function(){
        var laydate = layui.laydate;

        laydate.render({
            elem: '#start' //指定元素
            ,type: 'datetime'
            ,trigger: 'click'
        });

        laydate.render({
            elem: '#end' //指定元素
            ,type: 'datetime'
            ,trigger: 'click'
        });
    })
  });
  function del(id){
    swal_del(id,"{:url('delList')}")
  }

  function watch(content) {
    layui.use('layer', function(){
      var layer = layui.layer;
      layer.open({
          title :'预览',
          area: ['100%', '100%'],
          type: 1,
          content: content
        });
    });
  }
</script>
